<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}{% endblock %} - 智慧农业管理系统</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
    {% block extra_css %}{% endblock %}
    <style>
    /* 页面标题样式 */
    .page-header {
        background: white;
        padding: 20px 30px;
        margin: 0;
        position: sticky;
        top: 0;
        z-index: 100;
        width: 100%;
        border-bottom: 1px solid #eee;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    }

    .page-header h1 {
        margin: 0;
        color: #2c3e50;
        font-size: clamp(1.5em, 3vw, 2em);
    }

    /* 内容区域调整 */
    .content {
        padding: 0 30px 30px;
        margin-left: 250px;
        min-height: 100vh;
        background: #f8f9fa;
    }

    @media (max-width: 768px) {
        .content {
            margin-left: 0;
            padding: 0 20px 20px;
        }

        .page-header {
            padding: 15px 20px;
        }

        .main-nav {
            transform: translateX(-100%);
            transition: transform 0.3s ease;
        }

        .main-nav.active {
            transform: translateX(0);
        }

        .nav-toggle {
            display: block;
            position: fixed;
            top: 20px;
            left: 20px;
            z-index: 1000;
            background: #2c3e50;
            color: white;
            padding: 10px;
            border-radius: 5px;
            cursor: pointer;
            border: none;
        }
    }
    </style>
</head>
<body>
    <div id="app">
        <button class="nav-toggle" style="display: none;" onclick="toggleNav()">
            <i class="fas fa-bars"></i>
        </button>
        
        <nav class="main-nav">
            <div class="nav-header">
                <h2 style="color: white; margin-bottom: 20px;">智慧农业</h2>
            </div>
            <ul>
                <li><a href="{{ url_for('main.index') }}"><i class="fas fa-home"></i>首页</a></li>
                <li><a href="{{ url_for('main.field_management') }}"><i class="fas fa-map-marked-alt"></i>农田管理</a></li>
                <li><a href="{{ url_for('main.device_management') }}"><i class="fas fa-microchip"></i>设备管理</a></li>
                <li><a href="{{ url_for('main.decision') }}"><i class="fas fa-brain"></i>决策支持</a></li>
                <li><a href="{{ url_for('main.task_management') }}"><i class="fas fa-tasks"></i>任务管理</a></li>
                <li><a href="{{ url_for('main.user_management') }}"><i class="fas fa-users"></i>用户管理</a></li>
                <li><a href="{{ url_for('auth.logout') }}"><i class="fas fa-sign-out-alt"></i>退出登录</a></li>
            </ul>
        </nav>
        
        <main class="content">
            <div class="page-header">
                <h1>{% block page_title %}{% endblock %}</h1>
            </div>
            {% block content %}{% endblock %}
        </main>
    </div>
    
    <div id="loading" class="loading" style="display: none;"></div>
    
    {% block scripts %}{% endblock %}
    <script>
        // 全局加载动画
        function showLoading() {
            document.getElementById('loading').style.display = 'block';
        }
        
        function hideLoading() {
            document.getElementById('loading').style.display = 'none';
        }
        
        // 为所有表单添加加载动画
        document.addEventListener('DOMContentLoaded', function() {
            document.querySelectorAll('form').forEach(form => {
                form.addEventListener('submit', () => {
                    showLoading();
                });
            });

            // 检查屏幕宽度并显示/隐藏导航切换按钮
            function checkScreenSize() {
                const navToggle = document.querySelector('.nav-toggle');
                if (window.innerWidth <= 768) {
                    navToggle.style.display = 'block';
                } else {
                    navToggle.style.display = 'none';
                    document.querySelector('.main-nav').classList.remove('active');
                }
            }

            // 初始检查
            checkScreenSize();

            // 监听窗口大小变化
            window.addEventListener('resize', checkScreenSize);
        });

        // 导航栏切换
        function toggleNav() {
            document.querySelector('.main-nav').classList.toggle('active');
        }
    </script>
</body>
</html> 